{{- range $key, $value := .CandiVersionMap.k8s }}
  {{- $version := toString $key }}
  {{- if $value.ccm.vsphere }}
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-{{ $version | replace "." "-" }}
fromImage: common/distroless
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
  add: /src/.build/bin/vsphere-cloud-controller-manager.linux_amd64
  to: /bin/vsphere-cloud-controller-manager
  before: setup
docker:
  ENTRYPOINT: ["/bin/vsphere-cloud-controller-manager"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    {{- if semverCompare ">=1.29" $version }}
from: {{ $.Images.BASE_GOLANG_21_ALPINE_DEV }}
    {{- else if semverCompare ">=1.27" $version }}
from: {{ $.Images.BASE_GOLANG_20_ALPINE_DEV }}
    {{- else if semverCompare ">=1.25" $version }}
from: {{ $.Images.BASE_GOLANG_19_ALPINE_DEV }}
    {{- end }}
git:
- add: /{{ $.ModulePath }}modules/030-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
  to: /patches
  stageDependencies:
    install:
      - '**/*'
mount:
- fromPath: ~/go-pkg-cache
  to: /go/pkg
shell:
  beforeInstall:
  - apk add --no-cache make bash git mercurial patch rsync
  install:
  - git clone https://github.com/kubernetes/cloud-provider-vsphere.git /src
  - cd /src
  - git checkout {{ $value.ccm.vsphere }}
  - test -d /patches/{{ $version }} && for patchfile in /patches/{{ $version }}/*.patch ; do patch -p1 < ${patchfile} ; done
  - make build VERSION={{ $value.ccm.vsphere }}
  - chown 64535:64535 /src/.build/bin/vsphere-cloud-controller-manager.linux_amd64
  - chmod 0755 /src/.build/bin/vsphere-cloud-controller-manager.linux_amd64
  {{- end }}
{{- end }}
